package com.zxj.netty.component.impl;

import com.zxj.netty.component.AbsLoadBalance;
import io.netty.channel.ChannelFuture;

import java.util.List;
import java.util.Random;

/**
 * 随机负载均衡选择
 */
public class RandomLoadBalance extends AbsLoadBalance {

    protected ChannelFuture doSelect(List<ChannelFuture> serviceRepos) {
        int size = serviceRepos.size();
        Random random = new Random();

        return serviceRepos.get(random.nextInt(size));
    }
}
